package com.chkj.fbook.common.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.Properties;

/**
 * Created by hsh
 */
public class PropertiesReader {

    private Properties prop = new Properties();//属性集合对象

    public PropertiesReader() {
        try {
            prop.load(this.getClass().getResourceAsStream("/configure.properties"));//将属性文件流装载到Properties对象中
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public String getProperty(String property) {
        if (StringUtils.isBlank(property)) {
            return null;
        }
        return prop.getProperty(property);
    }

    public Integer getInt(String property) {
        if (StringUtils.isBlank(property)) {
            return null;
        }
        return Integer.parseInt(prop.getProperty(property));
    }

    public static void main(String[] args) {
        PropertiesReader propertiesReader = new PropertiesReader();
        String url = propertiesReader.getProperty("sms.ip");
        int port = propertiesReader.getInt("sms.port");
        System.out.println(url);
    }
}
